<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            padding:0;
            margin:0;
            list-style: none;
        }
        .tab{
            width:300px;
            height:300px;
            border:1px solid red;
            margin:100px auto;
        }
        .tab input{
            width:100px;
            height:30px;
            float:left;
        }
        .tab .active{
            background: paleturquoise;
            color:#fff;
        }
        .tab li{
            width:300px;
            height:270px;
            background: purple;
            font-size: 30px;
            color:#fff;
            text-align: center;
            line-height: 270px;
            display: none;
        }
        .tab .show{
            display: block;
        }
        .tab section{
            overflow: hidden;
        }
    </style>
    <script>
        window.onload=function(){
            var n = new Tab();
            n.show();
        }
        class Tab{
                constructor(){
                    this.aBtn=document.querySelectorAll('.btnBox input');
                    this.aLi=document.querySelectorAll('.tab li');
                }
                show(){
                    var _this=this;
                    for(let i=0; i<this.aBtn.length;i++){



                        this.aBtn[i].onclick=function(){
                         _this.fn(i);
                        };
                    }
                }
                fn(i){
                    for(var j=0;j<this.aBtn.length;j++){
                        this.aBtn[j].className='';
                        this.aLi[j].className='';
                    }
                    this.aLi[i].className='show';
                    this.aBtn[i].className='active';
                }
            }
    </script>
</head>
<body>
<div class="tab">
    <section class="btnBox">
        <input type="button" value="按钮1" class="active">
        <input type="button" value="按钮2">
        <input type="button" value="按钮3">
    </section>
    <ul>
        <li class="show">1</li>
        <li>2</li>
        <li>3</li>
    </ul>
</div>
</body>
</html>